﻿Imports System.CodeDom

Public Class DemoData

    Public Shared Sub CreateDemoXML(ByVal aXMLFile As String, ByVal aDeleteIfExist As Boolean, ByVal anApplicationPath As String)

        If System.IO.File.Exists(aXMLFile) Then
            If Not aDeleteIfExist Then Return
            System.IO.File.Delete(aXMLFile)
        End If

        'create some Classes
        Dim myListOfClasses As New List(Of ClassObject)
        For I1 As Int16 = 1 To 9
            'create some fields
            Dim myListOfPropertyObjects As New List(Of PropertyObject)
            Dim myMemberAttributeObject As New MemberAttributeObject() With {.Public = True}
            For I2 As Int16 = 1 To 9
                Dim myPropertyName As String = String.Format("Property_{0}_{1}", I1, I2)
                Dim myPropertyObject As New PropertyObject With {.Name = myPropertyName, _
                                                                 .MemberAttributeObject = myMemberAttributeObject, _
                                                                 .HasGet = True, _
                                                                 .HasSet = True, _
                                                                 .PropertyType = GetType(System.String).ToString}
                myListOfPropertyObjects.Add(myPropertyObject)
            Next

            'sample namespaces
            Dim myNamespacesToImport As New List(Of String)
            With myNamespacesToImport
                .Add("System.IO")
                .Add("System.Xml")
            End With
            Dim myClassName As String = String.Format("Class_{0}", I1)
            If I1 = 1 Then myClassName = "Object"
            Dim myClassObject As New ClassObject With {.MemberAttributeObject = myMemberAttributeObject, _
                                                       .ClassNamespaceName = "testnamespace", _
                                                       .ClientType = Reflection.TypeAttributes.Public, _
                                                       .Name = myClassName, _
                                                       .NamespacesToImport = myNamespacesToImport, _
                                                       .PropertyObjects = myListOfPropertyObjects}
            myListOfClasses.Add(myClassObject)
        Next
        'create the application
        Dim myApplication As New ApplicationObject With {.Name = "My Demo Application", _
                                                         .ApplicationDirectory = anApplicationPath, _
                                                         .ClassObjects = myListOfClasses, _
                                                         .GeneratorType = ApplicationObject.enmGeneratorType.VisualBasicAndCSharp, _
                                                         .BlankLinesBetweenMembers = True, _
                                                         .VerbatimOrder = True}

        myApplication.SaveApplicationObject(aXMLFile)

    End Sub

End Class
